<?php

namespace Tictactoe\Ai;

use Tictactoe\Game as Game;
use Tictactoe\Tool as Tool;
use Tictactoe\Ai\Population\Item as Item;

class Population {
    
    /**
     * @var Item[]
     */
    protected $items = array();
    
    /**
     * @var int 
     */
    protected $populationQty = 50;

    /**
     * @return int
     */
    public function getPopulationQty() {
        return $this->populationQty;
    }

    /**
     * @param int $populationQty
     */
    public function setPopulationQty($populationQty) {
        $this->populationQty = $populationQty;
    }

    public function getItems() {
        return $this->items;
    }
    
    public function delItem($key) {
        unset($this->items[$key]);
    }
    
    /**
     * @param Game $game
     * @param int $moveX
     * @param int $moveY
     * @param int $value
     */
    public function addItem(Game $game, $moveX, $moveY, $value) {
        
        $estimate = Estimate::getInstance($game);
       
        $estimateValue = $estimate->getEstimateForValue($value);

        $item = new Item($game, $moveX, $moveY, $value, $estimateValue );

        $this->items[] = $item;
    }

}
